package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.dto.UserDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.neusoft.elmboot.po.User;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1,#{salt})")
	public int insert(User user);

	@Select("select * from user where userId=#{userId} and password=#{password}")
	public User userLogin(User user);

	//根据用户id查询用户
	@Select("select * from user where userId=#{userId}")
	public User getUserById(String userId);

	@Select("select * from user where userId = #{userId}")
	public User findByUserId(String userId);

	@Update("update user set userName=#{userName},userSex=#{userSex} where userId=#{userId}")
    public int changeUserInfo(UserDTO user);

	@Update("update user set userImg=#{userImg} where userId=#{userId}")
	public int changeAvatar(User user);

	@Update("update user set password=#{newPassword} where userId=#{userId}")
	int changePassword(String userId, String newPassword);
}
